home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3b / directory.z / directory
Encoding:
Text File  |  2002-10-03  |  5.3 KB  |  133 lines

  1.  
  2.  
  3.  
  4. DDDDIIIIRRRREEEECCCCTTTTOOOORRRRYYYY((((3333BBBB))))                                                    DDDDIIIIRRRREEEECCCCTTTTOOOORRRRYYYY((((3333BBBB))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      opendir, readdir, telldir, seekdir, rewinddir, closedir, dirfd -
  10.      directory operations (4.3BSD)
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ttttyyyyppppeeeessss....hhhh>>>>
  14.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ddddiiiirrrr....hhhh>>>>
  15.  
  16.      DDDDIIIIRRRR ****ooooppppeeeennnnddddiiiirrrr((((cccchhhhaaaarrrr ****ffffiiiilllleeeennnnaaaammmmeeee))));;;;
  17.  
  18.      ssssttttrrrruuuucccctttt ddddiiiirrrreeeecccctttt ****rrrreeeeaaaaddddddddiiiirrrr((((DDDDIIIIRRRR ****ddddiiiirrrrpppp))));;;;
  19.  
  20.      lllloooonnnngggg tttteeeellllllllddddiiiirrrr((((DDDDIIIIRRRR ****ddddiiiirrrrpppp))));;;;
  21.  
  22.      vvvvooooiiiidddd sssseeeeeeeekkkkddddiiiirrrr((((DDDDIIIIRRRR ****ddddiiiirrrrpppp,,,, lllloooonnnngggg lllloooocccc))));;;;
  23.  
  24.      vvvvooooiiiidddd rrrreeeewwwwiiiinnnnddddddddiiiirrrr((((DDDDIIIIRRRR ****ddddiiiirrrrpppp))));;;;
  25.  
  26.      vvvvooooiiiidddd cccclllloooosssseeeeddddiiiirrrr((((DDDDIIIIRRRR ****ddddiiiirrrrpppp))));;;;
  27.  
  28.      iiiinnnntttt ddddiiiirrrrffffdddd((((DDDDIIIIRRRR ****ddddiiiirrrrpppp))))
  29.  
  30. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  31.      The inclusion of <_s_y_s/_d_i_r._h> selects the 4.3BSD versions of these
  32.      routines.  For the System V versions, include <_d_i_r_e_n_t._h>.
  33.  
  34.      _o_p_e_n_d_i_r opens the directory named by _f_i_l_e_n_a_m_e and associates a _d_i_r_e_c_t_o_r_y
  35.      _s_t_r_e_a_m with it.  _o_p_e_n_d_i_r returns a pointer to be used to identify the
  36.      _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m in subsequent operations.  The pointer NNNNUUUULLLLLLLL is returned
  37.      if _f_i_l_e_n_a_m_e cannot be accessed, or if it cannot _m_a_l_l_o_c(3) enough memory
  38.      to hold the whole thing.
  39.  
  40.      _r_e_a_d_d_i_r returns a pointer to the next directory entry.  It returns NNNNUUUULLLLLLLL
  41.      upon reaching the end of the directory or detecting an invalid _s_e_e_k_d_i_r
  42.      operation.
  43.  
  44.      _t_e_l_l_d_i_r returns the current location associated with the named _d_i_r_e_c_t_o_r_y
  45.      _s_t_r_e_a_m.
  46.  
  47.      _s_e_e_k_d_i_r sets the position of the next _r_e_a_d_d_i_r operation on the _d_i_r_e_c_t_o_r_y
  48.      _s_t_r_e_a_m. The new position reverts to the one associated with the _d_i_r_e_c_t_o_r_y
  49.      _s_t_r_e_a_m when the _t_e_l_l_d_i_r operation was performed.  Values returned by
  50.      _t_e_l_l_d_i_r are good only for the lifetime of the DIR pointer from which they
  51.      are derived.  If the directory is closed and then reopened, the _t_e_l_l_d_i_r
  52.      value may be invalidated due to undetected directory compaction.  It is
  53.      safe to use a previous _t_e_l_l_d_i_r value immediately after a call to _o_p_e_n_d_i_r
  54.      and before any calls to _r_e_a_d_d_i_r.
  55.  
  56.      _r_e_w_i_n_d_d_i_r resets the position of the named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m to the
  57.      beginning of the directory.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. DDDDIIIIRRRREEEECCCCTTTTOOOORRRRYYYY((((3333BBBB))))                                                    DDDDIIIIRRRREEEECCCCTTTTOOOORRRRYYYY((((3333BBBB))))
  71.  
  72.  
  73.  
  74.      _c_l_o_s_e_d_i_r closes the named _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m and frees the structure
  75.      associated with the DIR pointer.
  76.  
  77.      _d_i_r_f_d returns the integer file descriptor associated with the named
  78.      _d_i_r_e_c_t_o_r_y _s_t_r_e_a_m, see open(2).
  79.  
  80.      Sample code that searches a directory for entry ``name'':
  81.  
  82.           len = strlen(name);
  83.           dirp = opendir(".");
  84.           if (dirp == NULL) {
  85.               return NOT_FOUND;
  86.           }
  87.           while ((dp = readdir(dirp)) != NULL) {
  88.               if (dp->d_namlen == len && !strcmp(dp->d_name, name)) {
  89.                closedir(dirp);
  90.                return FOUND;
  91.               }
  92.           }
  93.           closedir(dirp);
  94.           return NOT_FOUND;
  95.  
  96.  
  97. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  98.      open(2), close(2), read(2), lseek(2), directory(3C)
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.